Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Integrate all routes from nutripatrol's API #991

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

Valimp
Copy link
Collaborator

@Valimp Valimp commented Nov 13, 2024

What

Add nutripatrol's routes to the dart SDK

Fixes bug(s)

#885

@Valimp Valimp changed the title Integrate all routes from nutripatrol's API feat: Integrate all routes from nutripatrol's API Nov 13, 2024
Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Valimp!
Please have a look at my comments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quickly said: test your code in test files, not in main.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll probably need to add the other nutripatrol classes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And nutripatrol_types.dart

@g123k g123k marked this pull request as ready for review January 10, 2025 09:31
@g123k g123k requested a review from a team as a code owner January 10, 2025 09:31
@g123k g123k requested a review from monsieurtanuki January 10, 2025 09:31
Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Valimp!
The code must pass the analysis tests.

@g123k
Copy link
Contributor

g123k commented Jan 10, 2025

@Valimp will have his midterms next week, that's why I've fixed the main warnings.
However the enum NutripatrolSource is declared twice.

Other than that, I think you can review the PR @monsieurtanuki

@monsieurtanuki
Copy link
Contributor

@Valimp will have his midterms next week
Other than that, I think you can review the PR

@g123k As you may know currently I don't have a computer, so code reviews are sometimes acrobatic and I don't want to review too often.
Besides, I already had a quick look at the code and I saw several things to fix. If @Valimp is busy, I don't see the point of reviewing now instead of when @Valimp is available.
Unless you're in a hurry and want to fix the code yourself.

Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Valimp!
Please have a look at my comments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use this file. Nobody does.
Please create unit tests for your new classes.

Comment on lines 52 to 53
export 'src/model/product_type.dart';
export 'src/model/product_type_filter.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some confusion with these guys: one is moved and copied, the other is not.

@Valimp Valimp requested a review from monsieurtanuki February 6, 2025 09:37
Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Valimp!
Please have a look at my comments.

import 'package:test/test.dart';

void main() {
setUpAll(() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use it in the other tests. Do you really need it? If so please add a specific comment.

@@ -0,0 +1,48 @@
import 'package:json_annotation/json_annotation.dart';

enum NutripatrolSource {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would

  • extend OffTagged
  • put each enum in a specific file
  • add "Nutripatrol" and remove "Enum" in your comments

But that's not mandatory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And nutripatrol_types.dart

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you should NOT change that file, please.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should test the other methods of Nutripatrol.
For instance, list the tickets and find the one you've just created.

@teolemon
Copy link
Member

teolemon commented Mar 4, 2025

@monsieurtanuki @g123k can we finally merge this ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the comment as it was.

import 'dart:math';

import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:openfoodfacts/src/nutripatrol/nutripatrol_types.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not supposed to be there, but in the list of exported dart files.

return MaybeError<CreateNutripatrolFlag>.value(
CreateNutripatrolFlag.fromJson(decodedResponse));
}
return MaybeError<CreateNutripatrolFlag>.responseError(response);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use try / catch for all your MaybeError statements, cf. prices.

@monsieurtanuki
Copy link
Contributor

@monsieurtanuki @g123k can we finally merge this ?

@teolemon Quickly said: no.

  • there are many unresolved conversations
  • in the enum types (nutripatrol_types.dart) a label field has been introduced instead of the widely used (and suggested) offTag
  • there are a couple of unwanted lines to remove in old_product_result.g.dart - this file isn't supposed to change, the specific comment is meant to be kept
  • I suspect that nutripatrol_types.dart isn't exported
  • suggested tests are missing, like testing if whatever we created can be retrieved afterwards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants